﻿
-- Start --

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

-- dnc_Advertiser --

CREATE TABLE [dbo].[dnc_Advertiser](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[UserId] [varchar](255) NULL,
 CONSTRAINT [PK_dnc_Advertiser] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

-- dnc_Image --

CREATE TABLE [dbo].[dnc_Image](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[Image] [varbinary](max) NOT NULL,
	[ContentType] [varchar](100) NOT NULL,
	[Height] [decimal](7, 2) NOT NULL,
	[Width] [decimal](7, 2) NOT NULL,
 CONSTRAINT [PK_dncImage] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

-- dnc_Advertisement --

CREATE TABLE [dbo].[dnc_Advertisement](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[ImageID] [int] NOT NULL,
	[AlternateText] [varchar](100) NOT NULL,
	[URL] [varchar](max) NOT NULL,
	[StartDate] [datetime] NOT NULL,
	[EndDate] [datetime] NOT NULL,
	[Active] [bit] NOT NULL,
	[AdvertiserID] [int] NOT NULL,
 CONSTRAINT [PK_dnc_Advertisement] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[dnc_Advertisement]  WITH CHECK ADD  CONSTRAINT [dnc_Advertisement_AdvertiserID_FK] FOREIGN KEY([AdvertiserID])
REFERENCES [dbo].[dnc_Advertiser] ([ID])
GO
ALTER TABLE [dbo].[dnc_Advertisement] CHECK CONSTRAINT [dnc_Advertisement_AdvertiserID_FK]
GO
ALTER TABLE [dbo].[dnc_Advertisement]  WITH CHECK ADD  CONSTRAINT [dnc_Advertisement_ImageID_FK] FOREIGN KEY([ImageID])
REFERENCES [dbo].[dnc_Image] ([ID])
GO
ALTER TABLE [dbo].[dnc_Advertisement] CHECK CONSTRAINT [dnc_Advertisement_ImageID_FK]

GO
SET ANSI_PADDING ON
GO

-- dnc_ClickThrough --

CREATE TABLE [dbo].[dnc_ClickThrough](
	[AdvertisementID] [int] NOT NULL,
	[ClickThrough] [datetime] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[dnc_ClickThrough]  WITH CHECK ADD  CONSTRAINT [dnc_ClickThrough_AdvertisementID_FK] FOREIGN KEY([AdvertisementID])
REFERENCES [dbo].[dnc_Advertisement] ([ID])
GO
ALTER TABLE [dbo].[dnc_ClickThrough] CHECK CONSTRAINT [dnc_ClickThrough_AdvertisementID_FK]

GO

-- dnc_Impression --

CREATE TABLE [dbo].[dnc_Impression](
	[AdvertisementID] [int] NOT NULL,
	[Impression] [datetime] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[dnc_Impression]  WITH CHECK ADD  CONSTRAINT [dnc_Impression_AdvertisementID_FK] FOREIGN KEY([AdvertisementID])
REFERENCES [dbo].[dnc_Advertisement] ([ID])
GO
ALTER TABLE [dbo].[dnc_Impression] CHECK CONSTRAINT [dnc_Impression_AdvertisementID_FK]
GO

-- dnc_ZoneImage --
CREATE TABLE [dbo].[dnc_ZoneImage](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[ImageWidth] [decimal](7, 2) NOT NULL,
	[ImageHeight] [decimal](7, 2) NOT NULL,
 CONSTRAINT [PK_dnc_ZoneImage] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

-- dnc_Zone --

CREATE TABLE [dbo].[dnc_Zone](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](255) NOT NULL,
	[ZoneImageId] [int] NOT NULL,
 CONSTRAINT [PK_dnc_Zone] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[dnc_Zone]  WITH CHECK ADD  CONSTRAINT [FK_dnc_Zone_dnc_ZoneImage] FOREIGN KEY([ZoneImageId])
REFERENCES [dbo].[dnc_ZoneImage] ([Id])
GO
ALTER TABLE [dbo].[dnc_Zone] CHECK CONSTRAINT [FK_dnc_Zone_dnc_ZoneImage]
GO

-- dnc_AdvertisementZone --

GO
CREATE TABLE [dbo].[dnc_AdvertisementZone](
	[AdvertisementID] [int] NOT NULL,
	[ZoneID] [int] NOT NULL
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[dnc_AdvertisementZone]  WITH CHECK ADD  CONSTRAINT [FK_dnc_AdvertisementZone_dnc_Advertisement] FOREIGN KEY([AdvertisementID])
REFERENCES [dbo].[dnc_Advertisement] ([ID])
GO
ALTER TABLE [dbo].[dnc_AdvertisementZone] CHECK CONSTRAINT [FK_dnc_AdvertisementZone_dnc_Advertisement]
GO
ALTER TABLE [dbo].[dnc_AdvertisementZone]  WITH CHECK ADD  CONSTRAINT [FK_dnc_AdvertisementZone_dnc_Zone] FOREIGN KEY([ZoneID])
REFERENCES [dbo].[dnc_Zone] ([ID])
GO
ALTER TABLE [dbo].[dnc_AdvertisementZone] CHECK CONSTRAINT [FK_dnc_AdvertisementZone_dnc_Zone]
GO
-- End --


SET ANSI_PADDING OFF
GO

